/**
 * In me the tiger sniffs the rose.
 *
 * @Author:徐家政
 * @Date:2019-04-18 22:16
 */
package com.shiyu.demo.controller;

import com.shiyu.demo.service.PostCommentListService;
import com.shiyu.demo.util.R;
import com.shiyu.demo.util.ResultData;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@CrossOrigin
public class PostCommentListController {
    @Resource
    private PostCommentListService postCommentListService;
    @RequestMapping("/community/postreview")
    public ResultData getCommentList(Integer postId, Integer pageNum){

        return postCommentListService.getCommentList(postId, pageNum);
    }
    @RequestMapping("/community/uptop")
    public R upTop(Integer id){
        Integer i =postCommentListService.updateCommentTop(id);
        if (i!=0){
            return R.ok();
        }
        return R.error("开了个小差,请稍后重试");
    }
    @RequestMapping("/community/addcomment")
    public R addComment(Integer userid, String comment, Integer postid){
        int i= postCommentListService.addComment( userid,  comment,  postid);
        if (i==0){
            return R.error("失败,网络开小差了");
        }
        return R.ok();
    }
}
